package com.adcc.loadsheet.billing.service.impl;

import com.adcc.loadsheet.billing.mapper.mysql.MysqlMapper;
import com.adcc.loadsheet.billing.service.BillingDataMoveService;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by AN on 2020-06-19.
 */
@Service
public class BillingDataMoveServiceImpl implements BillingDataMoveService {

    @Autowired
    private MysqlMapper mysqlMapper;

    @Override
    public Map<String, Object> getTips() {
        Map<String, Object> data= Maps.newHashMap();
        data.put("Tip1","");
        data.put("Tip2","");
        String lastdatetime=mysqlMapper.getUpdateBaseTime();
        List<String> datelist=mysqlMapper.getFaildate();
        String dates="";
        if(datelist!=null&&datelist.size()>0){
            dates=String.join(";", datelist);
        }
        if(!Strings.isNullOrEmpty(lastdatetime)){
            String tip1="注：基础数据最新更新时间："+lastdatetime;
            data.put("Tip1",tip1);
            if(!Strings.isNullOrEmpty(dates)){
                String tip2="舱单更新失败日期："+dates;
                data.put("Tip2",tip2);
            }
        }else if(!Strings.isNullOrEmpty(dates)){
            String tip1="注：舱单更新失败日期："+dates;
            data.put("Tip1",tip1);
        }

        return data;
    }
}
